﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lamex.mCost.Common
{
    public class ServerDBHelper
    {
        //public void WriteServerInfo()
        //{
        //    Lamex.Common.IniFile ini = new Lamex.Common.IniFile(Application.StartupPath + "\\config\\CSFramework3.ini");
        //    ini.IniWriteValue("SQL Configuration_41", "UserID_41", "sa");
        //    ini.IniWriteValue("SQL Configuration_41", "PassWord_41", "Sa@1050%");
        //    ini.IniWriteValue("SQL Configuration_41", "ServerID_41", "LamexMESManager");
        //    ini.IniWriteValue("SQL Configuration_41", "DataBase_41", "172.23.134.29");
        //}
        public static string GetSql(string sql)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("exec sp_addlinkedserver 'srv_lnk','','sqloledb','172.23.134.29' ");
            builder.Append("\r\n");
            builder.Append("exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'sa','Sa@1050%' ");
            builder.Append("\r\n");
            builder.Append("go ");
            builder.Append("\r\n");
            builder.Append(sql);
            builder.Append("\r\n");
            builder.Append("go ");
            builder.Append("\r\n");
            builder.Append("exec sp_dropserver 'srv_lnk','droplogins' ");
            return builder.ToString();
        }
    }
}
